// 原来保存当前登录用户的信息
const STORAGE_USER = 'login-user'
export default{
  fetch_user () {
    return JSON.parse(window.localStorage.getItem(STORAGE_USER) || '{}')
  },

  // 获取发起审批权限  审批发起权限 名称： todo: 暂时如此设置  startApprove
  getStartApprove (router) {
    var resourceList = []
    resourceList.push(JSON.parse(window.localStorage.getItem(STORAGE_USER) || '{}').resources)
    // console.log('资源：'+resourceList);
    let url = router + '-startApprove'
    for (var i = 0; i < resourceList[0].length; i++) {
      if (url === resourceList[0][i]) { // 拼接address
        return true
      }
      // return true;  //todo: 正式使用后 将此处注释掉
    }
    return false
  },
  save_user (items) {
    window.localStorage.setItem(STORAGE_USER, JSON.stringify(items))
  },
  remove_user () {
    window.localStorage.removeItem(STORAGE_USER)
  }
}
